package DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import table.TeacherScore_View;
import util.BaseConnection;

public class TeacherScore_View_DAO {
	public ArrayList<TeacherScore_View> getList(String tid,String cid){
		ArrayList<TeacherScore_View> ar = new ArrayList<TeacherScore_View>();
		Connection conn = BaseConnection.getConnection();
		PreparedStatement ps = null;
		ResultSet rs = null;
		String sql = "select * from TeacherScore_View where Teacher_id = ? and Course_id = ?";
		
		try {
			ps = conn.prepareStatement(sql);
			ps.setString(1, tid);
			ps.setString(2, cid);
			rs = ps.executeQuery();
			while (rs.next()) {
				TeacherScore_View obj = new TeacherScore_View();
				obj.setTeacher_id(rs.getString("Teacher_id"));
				obj.setTeacher_name(rs.getString("Teacher_name"));
				obj.setCourse_id(rs.getString("Course_id"));
				obj.setCourse_name(rs.getString("Course_name"));
				obj.setStudent_id(rs.getString("Student_id"));
				obj.setStudent_name(rs.getString("Student_name"));
				obj.setGrade_first(rs.getString("Grade_first"));
				obj.setGrade_second(rs.getString("Grade_second"));
				obj.setGrade_rebuild(rs.getString("Grade_rebuild"));
				obj.setCredit(rs.getString("Credit"));
				obj.setBJ_name(rs.getString("BJ_name"));
				ar.add(obj);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		return ar;
	}
}
